home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / miscpas.zip / OHM2.PAS < prev    next >
Pascal/Delphi Source File  |  1984-07-01  |  35KB  |  873 lines

  1.  
  2.  
  3. Program DC_Circuits2;
  4.  
  5. Var  Xlow,Yhi,Vlen,Hlen,I  : Integer;   (* Box locator and lengths.*)
  6.                 Xpos,Ypos  : Integer;   (* Locate circit diagrams. *)
  7.             Low,High,Nres  : Integer;   (* Circuit choice. *)
  8.                   V,A,R,W  : Real;      (* Circuit totals. *)
  9.               V1,A1,R1,W1  : Real;
  10.               V2,A2,R2,W2  : Real;
  11.               V3,A3,R3,W3  : Real;
  12.                     Zh,Ch  : Char;
  13.    Serflag,Parflag,Spflag  : Boolean;
  14.                   Ccontrol : File;
  15.                    Label      Mainlab;
  16. {========================================================================}
  17.  
  18. Procedure Key;  Begin
  19.   Gotoxy(27,25); Write(' Press any key ');
  20.   Repeat until Keypressed;
  21.   Gotoxy(26,25); Write('                   ');
  22. end;   (* Procedure Key.*)
  23.  
  24. {========================================================================}
  25.  
  26.                        Procedure MainControl; forward;
  27. Procedure Node;  Begin
  28.  
  29. Gotoxy(22,25);Write('Press `M` for Menu, `Q` to Quit.');
  30.  
  31.   Repeat
  32.     Read(Kbd,ch);
  33.     ch:=UpCase(ch);
  34.   until (Ch in ['M','Q']);
  35. Gotoxy(14,25);Write('                                                     ');
  36.  
  37. If (Ch='M') then MainControl;
  38. If (Ch='Q') then begin
  39.               Textmode(2); Halt;
  40.             end;
  41. end;  (* Procedure Node. *)
  42.  
  43. {========================================================================}
  44. Procedure ShortCircuit;
  45.                           Var I : Integer;
  46. Begin    ClrScr;
  47.  
  48.   TextMode(0);
  49.     For I:= 1 to 6 do begin
  50.       Gotoxy(12,12);
  51.         Write('Short Circuit!');
  52.       Delay(100);
  53.         ClrScr;
  54.       Delay(100);
  55.     end;
  56.   Textmode(2);
  57. end;
  58. {-----------------------------------------------------------------------}
  59.  
  60. (*      Box drawing procedure.  Define by upper left corner and
  61.           lengths of horizontal and vertical lines.  Xlow,Yhi
  62.               and lengths input just before Boxes call.
  63. *)
  64. Procedure Boxes;         (*  Upper left corner x,y and side    *)
  65.                          (* lengths come from calling program. *)
  66.  
  67. Var Hl, Vl, Ur, Ul, Ll, Lr : Char;      (* Lines and Corners. *)
  68.  
  69. Begin
  70.  
  71.  Hl:=Char(196); Vl:=Char(179);
  72.  Ur:=Char(191); Ul:=Char(218); Ll:=Char(192); Lr:=Char(217);
  73.  
  74. Gotoxy(Xlow, Yhi);   Write(Ul);     (* Position upper left corner. *)
  75.   For I:=1 to Hlen do begin         (* Write top line and corners. *)
  76.      Write(Hl);
  77.   end;
  78.     Write(Ur);
  79.  
  80.     Xlow:=Xlow+Hlen+1;              (*   X is same for vertical.    *)
  81.   For I:=1 to Vlen do begin         (*  Write R vertical and corner.*)
  82.     Yhi:=Yhi+1;
  83.       Gotoxy(Xlow, Yhi);
  84.         Write(Vl);
  85.   end;
  86. Gotoxy(Xlow, Yhi+1);  Write(Lr);
  87.  
  88.     Yhi:=Yhi+1;
  89.   For I:=1 to Hlen do begin         (*  Y same for horizontal.*)
  90.     Xlow:=Xlow-1;
  91.       Gotoxy(Xlow, Yhi);
  92.         Write(Hl);
  93.   end;
  94. Gotoxy(Xlow-1, Yhi);  Write(Ll);
  95.  
  96.     Xlow:=Xlow-1;                   (*  X same for vertical. *)
  97.   For I:=1 to Vlen do begin
  98.     Yhi:=Yhi-1;
  99.       Gotoxy(Xlow, Yhi);
  100.         Write(Vl);
  101.   end;
  102. end;   (* Procedure Boxes. *)
  103. {---------------------------------------------------------------------}
  104.  
  105. Procedure SerDraw;        (* Draws diagram for Series Circuit. *)
  106.  
  107. Var         Hline : Char;
  108.  
  109. Begin
  110.   Hline:=Char(196);
  111.     Gotoxy(Xpos,Ypos);
  112.  
  113.       For I:=1 to 17 do begin
  114.         Write(Hline);
  115.       end;
  116.  
  117.   Gotoxy(Xpos-2, Ypos);  Write('V+');
  118.   Gotoxy(Xpos+2, Ypos);  Write('R1');
  119.   Gotoxy(Xpos+7, Ypos);  Write('R2');
  120.   Gotoxy(Xpos+12,Ypos);  Write('R3');
  121.   Gotoxy(xPos+16,Ypos);  Write('-' );
  122. End;  (* SerDraw *)
  123. {-------------------------------------------------------------------}
  124.  
  125. Procedure ParDraw;       (* Draws diagram for Parallel Circuit. *)
  126.  
  127. Var         Hline : Char;
  128.  
  129. Begin
  130.  
  131.     Xlow:= Xpos+4; Yhi:=Ypos-2;      (* Box corner position.    *)
  132.       Vlen:=3;         Hlen:=6;      (* Side lengths (globals). *)
  133.  
  134. Boxes;                        (* Call Boxes. *)
  135.  
  136.   Hline:=Char(196);
  137.  
  138.     Gotoxy(Xpos,Ypos);
  139.     Write('V+');
  140.       For I:=1 to 12 do begin
  141.         Write(Hline);
  142.       end;
  143.     Write('-');
  144.  
  145.    Gotoxy(Xpos+ 4, Ypos);  Write(char(197));
  146.    Gotoxy(Xpos+11, Ypos);  Write(char(197));
  147.  
  148.   Gotoxy(Xpos+7, Ypos-2);  Write('R1');
  149.   Gotoxy(Xpos+7, Ypos  );  Write('R2');
  150.   Gotoxy(Xpos+7, Ypos+2);  Write('R3');
  151. End;  (* ParDraw. *)
  152. {-----------------------------------------------------------------}
  153.  
  154. Procedure SPDraw;       (*  Draws Series-Parallel diagram. *)
  155.  
  156. Var         Hline : Char;
  157.  
  158. Begin
  159.   Hline:=Char(196);
  160.     Gotoxy(Xpos,Ypos);
  161.         Write('V+');
  162.       For I:=1 to 6 do begin
  163.         Write(Hline);
  164.       end;
  165.     Write(char(180));
  166.  
  167.     Gotoxy(Xpos+15,Ypos);
  168.     Write(char(195));
  169.       For I:=1 to 2 do begin
  170.         Write(Hline);
  171.       end;
  172.     Write('-');
  173.   Xlow:=Xpos+8;  Yhi:=Ypos-2;
  174.   Vlen:=3;      Hlen:=6;
  175. Boxes;       (*  Call Boxes. *)
  176.  
  177.   Gotoxy(Xpos+11, Ypos-2);  Write('R2');
  178.   Gotoxy(Xpos+ 4, Ypos  );  Write('R1');
  179.   Gotoxy(Xpos+11, Ypos+2);  Write('R3');
  180. End;    (* SPDraw *)
  181. {-------------------------------------------------------------------}
  182.  
  183. Procedure TableBod;
  184. begin
  185.  
  186. Gotoxy(25,6);
  187.                           Writeln(' Flow is Amps   V = AR    ');
  188.   Writeln('                         ~~~~~~~~~~~~   ~~~~~~    ');
  189.   Writeln('----------|---------|--------|--------|--------|  ');
  190.   Writeln('          |  Total  |   R1   |   R2   |   R3   |  ');
  191.   Writeln('==========|=========|========|========|========|  ');
  192.   Writeln('Resistors |         |        |        |        |  ');
  193.   Writeln('  Amps    |         |        |        |        |  ');
  194.   Writeln('  Volts   |         |        |        |        |  ');
  195.   Writeln('----------|---------|--------|--------|--------|  ');
  196.   Writeln('  Watts   |         |        |        |        |  ');
  197.   Writeln('------------------------------------------------  ');
  198. end;
  199.   {---------------------------------------------------------------}
  200.  
  201. Procedure ResRead;     (* Input Resistors and Volts. *)
  202. Begin                  (*    SEE PAGE 94 of Zwass.   *)
  203.  
  204.                       (*  Different for each circuit!  *)
  205.   If (Spflag=false) then Read(Nres);
  206.   If (Spflag=true)  then Nres:=3;
  207.  
  208.   If (Serflag=true) and (Nres<=0) then Nres:=1;
  209.   If (Serflag=true) and (Nres>3)  then Nres:=3;
  210.  
  211.   If (Parflag=True) and (Nres<2) then Nres:=2;
  212.   If (Parflag=True) and (Nres>3) then Nres:=3;
  213.  
  214.     Gotoxy(52,11); Write('Ohms of R1 is: '); Read(R1);
  215.       Gotoxy(22,11); Write(R1:6:0);
  216.         R:=R1;
  217.   If Nres >=2 then begin
  218.     Gotoxy(52,12); Write('Ohms of R2 is: '); Read(R2);
  219.       Gotoxy(31,11); Write(R2:6:0);
  220.         R:=R+R2;
  221.           end;
  222.   If Nres=3 then begin
  223.     Gotoxy(52,13); Write('Ohms of R3 is: '); Read(R3);
  224.       Gotoxy(40,11); Write(R3:6:0);
  225.         R:=R+R3;
  226.           end;
  227. Gotoxy(51,15); Write('Circuit volts is: ');  Read(V);
  228.   Gotoxy(14,13); Write(V:5:2);
  229.   Gotoxy(13,11); If Serflag=true then Write(R:6:0);
  230. end;    (* ResRead *)
  231.   {----------------------------------------------------------------}
  232.  
  233. Procedure SerMath;
  234. Begin
  235.  
  236. Writeln('          Series Circuits (Volts sum).       ');
  237. Writeln('          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ');
  238. Writeln('   Total Resistance :  R  = R1 + R2 + R3.    ');
  239. Writeln('   Total Amps       :  A  = V/R.             ');
  240. Writeln('    Volts drops     :  V1 = AR1  [AR2, AR3]. ');
  241. Writeln('      Watts         :  W  = A',#253,'R.            ');
  242. end;
  243.  {--------------------------------------------------------}
  244.  
  245. Procedure Parmath;
  246. Begin
  247. Writeln('         PARALLEL CIRCUITS (Amps sum).      ');
  248. Writeln('         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      ');
  249. Writeln('  Total Resistance:  Rt = 1/(1/R1+1/R2+1/R3)');
  250. Writeln('  Total Amps      :  A  = V/R.              ');
  251. Writeln('   Amps for each R:  A1 = V/R1  [V/R2, V/R3]');
  252. Writeln('     Watts        :  W  = A',#253,'R.             ');
  253. end;
  254.   {-----------------------------------------------------------------}
  255.  
  256. Procedure SPmath;
  257. Begin
  258.  
  259. Writeln('              SERIES-PARALLEL   ');
  260. Writeln('              ~~~~~~~~~~~~~~~   ');
  261. Writeln('  * Equivalent Res.: Rp = R2xR3/(R2 + R3).     ');
  262. Writeln('  Total Resistance : R  = R1 + Rp.             ');
  263. Writeln('  Total Amps       : A  = V/R.                 ');
  264. Writeln('   R1 volts drop   : V1 = AR1.                 ');
  265. Writeln('   Parallel`s Amps : A2 = (V-V1)/R2 [(V-V1)/R3]');
  266. Writeln('     Watts         : W  = A',#253,'R.                 ');
  267. end;
  268.   {---------------------------------------------------------------}
  269.  
  270. Procedure Series;             (* All math variables global. *)
  271.  
  272. Begin
  273.         Clrscr;  Ch:='Z';        Serflag:=true;
  274.                  Parflag:=false;  Spflag:=false;
  275.  
  276. Gotoxy(27,2);  Write('SERIES CIRCUIT');
  277.  
  278.   Xpos:=6;  Ypos:=4;  Serdraw;
  279.  
  280.                       Tablebod;
  281.     Gotoxy(1,18);     SerMath;
  282.   Xlow:=2; Yhi:=17;
  283.   Vlen:=6; Hlen:=42;  Boxes;        (* Around SerMath. *)
  284.  
  285. Gotoxy(51,9);  Write('How many Resistors? ');
  286.                       ResRead;      (* Read resistors and volts. *)
  287.  
  288. If R=0 then ShortCircuit;
  289. If R=0 then Series;
  290.  
  291. A:=V/R;                             (* Compute body of table. *)
  292.   Gotoxy(14,12);  Write(A:6:3);
  293. W:=A*A*R;
  294.   Gotoxy(14,15);  Write(W:6:2);
  295.     If Nres>=2 then begin
  296.       Gotoxy(23,12);  Write(A:6:3);
  297.       Gotoxy(32,12);  Write(A:6:3);
  298.         V1:=A*R1;
  299.         V2:=A*R2;
  300.       Gotoxy(24,13);  Write(V1:5:2);
  301.       Gotoxy(33,13);  Write(V2:5:2);
  302.         W1:=A*A*R1;
  303.         W2:=A*A*R2;
  304.       Gotoxy(23,15);  Write(W1:6:2);
  305.       Gotoxy(32,15);  Write(W2:6:2);
  306.     end;
  307.  
  308.     If Nres=3 then begin
  309.         V3:=A*R3;
  310.         W3:=A*A*R3;
  311.       Gotoxy(41,12);  Write(A:6:3);
  312.       Gotoxy(42,13);  Write(V3:5:2);
  313.       Gotoxy(41,15);  Write(W3:6:2);
  314.     end;
  315. end;   (* Series*)
  316.   {---------------------------------------------------------------}
  317.  
  318. Procedure Parallel;
  319. Begin
  320.   Clrscr;   Ch:='Z';        Parflag:=true;
  321.             Serflag:=false;  Spflag:=false;
  322.  
  323. Gotoxy(27,2);  Write('PARALLEL CIRCUIT');
  324.  
  325. Xpos:=6;  Ypos:=4;     Pardraw;    (* Call procedures.*)
  326.                        Tablebod;
  327.   Gotoxy(1,18);        ParMath;
  328.   Xlow:=1; Yhi:=17;
  329.   Vlen:=6; Hlen:=44;   Boxes;
  330.  
  331.   Gotoxy(51,8);
  332.   Write('Choose 2 or 3 R`s! ');
  333.               Resread;
  334. Gotoxy(23,13);  Write(V:5:2);      (*  Write volts in all cells. *)
  335. Gotoxy(32,13);  Write(V:5:2);
  336.   If Nres=3 then begin
  337.     Gotoxy(41,13);  Write(V:5:2);
  338.   end;
  339.  
  340. If (Nres=2) and ((R1=0) or (R2=0)) then begin   (* Short Circuit!. *)
  341.    ShortCircuit;
  342.      Parallel;
  343. end;
  344. If (Nres=3) and ((R1=0) or (R2=0) or (R3=0)) then begin
  345.   ShortCircuit;
  346.     Parallel;
  347. end;
  348.  
  349.     R:=1/R1+1/R2;                    (* Compute and write total R. *)
  350.  
  351. If Nres=3 then begin
  352.     R:=R+1/R3;
  353. end;
  354.     R:=1/R;
  355.  
  356. Gotoxy(12,11);  Write(R:7:1);
  357.  
  358. A:=V/R;                             (*  Compute and write A`s. *)
  359.   If R1>0 then A1:=V/R1;
  360.   If R2>0 then A2:=V/R2;
  361.  
  362. If (Nres=3) and (R3>0) then A3:=V/R3;
  363.  
  364.   Gotoxy(13,12);  Write(A:7:3);
  365.   Gotoxy(23,12);  Write(A1:6:3);
  366.   Gotoxy(32,12);  Write(A2:6:3);
  367. If Nres=3 then begin
  368.   Gotoxy(41,12);  Write(A3:6:3);
  369.     end;
  370.  
  371. W:=A*A*R;  W1:=A1*A1*R1;  W2:=A2*A2*R2; (* Compute & write watts.*)
  372.            If Nres=3 then W3:=A3*A3*R3;
  373.  
  374.   Gotoxy(13,15);  Write(W:7:2);
  375.   Gotoxy(23,15);  Write(W1:6:2);
  376.   Gotoxy(32,15);  Write(W2:6:2);
  377. If Nres=3 then begin
  378.   Gotoxy(41,15);  Write(W3:6:2);
  379.     end;
  380.  
  381. end;  (* Parallel *)
  382.   {---------------------------------------------------------------}
  383.  
  384. Procedure SerPar;
  385.  
  386.       Var  Re,Vp : Real;
  387. Begin
  388.   Clrscr;   Ch:='Z';          Spflag:=true;
  389.             Serflag:=false;  Parflag:=false;
  390.  
  391.     Gotoxy(28,2);  Write('SERIES-PARALLEL');
  392.  
  393.   Xpos:=3; Ypos:=4;    Spdraw;
  394.                        Tablebod;
  395.   Gotoxy(1,17);        Spmath;
  396.   Xlow:=1; Yhi:=16;
  397.   Vlen:=7; Hlen:=46;   Boxes;
  398.   Gotoxy(51,8);
  399.   Write('Enter values for 3 R`s:');
  400.                        Resread;
  401. If (R1=0) and ((R2=0) or (R3=0)) then
  402.   begin
  403.     ShortCircuit;
  404.     SerPar;
  405.   end;
  406.  
  407. If (R2+R3)<>0 then Re:=R2*R3/(R2+R3);   (*  Total resistance.*)
  408. R :=R1+Re;
  409.   Gotoxy(12,11);  Write(R:7:1);
  410.  
  411.     A:=V/R;  V1:=A*R1;                   (*  Amps and volts. *)
  412.    Vp:=V-V1;
  413.  
  414. If R2<>0 then A2:=Vp/R2;
  415. If R3<>0 then A3:=Vp/R3;
  416.  
  417. Gotoxy(13,12);  Write(A:7:3);
  418. Gotoxy(23,12);  Write(A:6:3);
  419. Gotoxy(32,12);  Write(A2:6:3);
  420. Gotoxy(41,12);  Write(A3:6:3);
  421.  
  422. Gotoxy(23,13);  Write(V1:6:2);
  423. Gotoxy(32,13);  Write(Vp:6:2);
  424. Gotoxy(41,13);  Write(Vp:6:2);
  425.  
  426.    W:=A*A*R;                                  (*  Watts. *)
  427. If R1<>0 then W1:= A*A*R1  else W1:=0;
  428. If R2<>0 then W2:=A2*A2*R2 else W2:=0;
  429. If R3<>0 then W3:=A3*A3*R3 else W3:=0;
  430.  
  431. Gotoxy(13,15);  Write(W:7:2);
  432. Gotoxy(23,15);  Write(W1:6:2);
  433. Gotoxy(32,15);  Write(W2:6:2);
  434. Gotoxy(41,15);  Write(W3:6:2);
  435.  
  436.  
  437. end;   (* SerPar *)
  438.   {---------------------------------------------------------------}
  439.  
  440. Procedure AllMath;        (* Puts all math computing on screen. *)
  441. Begin
  442.        ClrScr;   Ch:='Z';
  443.  
  444.   Gotoxy(1,2);        Sermath;
  445.   Xlow:=1; Yhi:=1;
  446.   Vlen:=5; Hlen:=44;  Boxes;
  447.  
  448.   Gotoxy(1,9);        Parmath;
  449.   Xlow:=1; Yhi:=8;
  450.   Vlen:=6; Hlen:=44;  Boxes;
  451.  
  452.   Gotoxy(1,17);       Spmath;
  453.   Xlow:=1; Yhi:=16;
  454.   Vlen:=8; Hlen:=46;  Boxes;
  455.  
  456.   Gotoxy(51,19);  Write('Press key for choice.');
  457.   Gotoxy(52,22);  Write('`M` Back to Menu.');
  458.   Gotoxy(52,23);  Write('`Q` Quit.');
  459.  
  460.     Repeat
  461.       Read(Kbd,ch);
  462.       ch:=UpCase(ch);
  463.     until (Ch IN ['M','Q']);
  464.  
  465. If Ch='M' then MainControl;
  466. If Ch='Q' then Halt;
  467.  
  468. end;   (*  AllMath  *)
  469.  
  470. {===================================================================}
  471.                       {   Procedure Maincontrol; Forward; }
  472. Procedure MathExplain;
  473.   Begin
  474.     Clrscr;
  475.   Gotoxy(1,5);
  476. Writeln('                 The Mathematics of Flow in Circuits.                  ');
  477. Writeln('                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                  ');
  478. Writeln('       Electronics is about electron-flow in circuits or `loops.`  ');
  479. Writeln('       We discussed Ohm`s law in the program Ohm1.  It is a math   ');
  480. Writeln('                expression to relate the 3 parts of flow:             ');
  481. Writeln('        Volts (pressure), Ohms (resistance), and Amps (amount).     ');
  482.   Key;Gotoxy(1,12);
  483. Writeln('       Flow rates (amps per second) are enormously different in var-  ');
  484. Writeln('       ious sitations.  Tiny trickles of current occur in some.  In   ');
  485. Writeln('       others, huge quantities flow.  We saw that one math express-   ');
  486. Writeln('       ion, a linear equation, describes many situations.             ');
  487.   Key;Gotoxy(1,17);
  488. Writeln('       For most applications, however, we have just one `flow pattern.`');
  489. Writeln('       We design the pattern (circuit) to provide the proper pressure  ');
  490. Writeln('       and current where we want it.   With good design, the circuit   ');
  491. Writeln('       does something useful.  That`s what design is about!            ');
  492.   Key;Gotoxy(1,25); For I:=1 to 5 do writeln;
  493.   Gotoxy(1,17);
  494. Writeln('       To understand circuits, we must look at them from two view-     ');
  495. Writeln('       points:  First, the circuit a whole, and Second, its various    ');
  496. Writeln('       parts.  Ohm`s law describes flow everywhere, so it applies to   ');
  497. Writeln('       the whole circuit and its parts.   The pressure and current    ');
  498. Writeln('       that gets to each resistor depends on the design.  There are ');
  499. Writeln('            2 basic configurations.  We consider details next.       ');
  500. Writeln('            --------------------------------------------------       ');
  501.  
  502.   Key;Clrscr;
  503.  
  504.   Xpos:=9;   Ypos:=6;   Serdraw;
  505.   Xpos:=30;  Ypos:=6;   Pardraw;
  506.   Xpos:=50;  Ypos:=6;   SPdraw;
  507.   Xlow:=3; Yhi:=3;
  508.   Vlen:=7; Hlen:=69;    Boxes;
  509. Gotoxy(13,10);Write('SERIES               PARALLEL                  BOTH');
  510. Gotoxy(20,1);Write('Overview of Flow and Mathematics.');
  511. Gotoxy(20,2);Write('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
  512.   {-------------------------------------------------------}
  513. Gotoxy(1,13);
  514. Writeln('     Our 3 basic circuits again.  Study them as you ponder these facts.  ');
  515.    Key;Gotoxy(1,13);
  516. Writeln('     Power is needed to push electrons, so start with the power source. ');
  517.    Key;Gotoxy(1,15);
  518. Writeln('      All current leaving the power source returns to it, like water     ');
  519. Writeln('                      pumped in a closed pipe loop.                                      ');
  520.   Key;Gotoxy(1,18);
  521. Writeln('      The current is in one loop (series), or it`s divided (parallel).   ');
  522.   Key;Gotoxy(1,20);
  523. Writeln('     Our math arises from these facts, and it`s simple.  Most circuits ');
  524. Writeln('      are intricate, however, so careful attention to the symbols for  ');
  525. Writeln('           circuit parts is essential.  But never forget FLOW!       ');
  526. Writeln('           ---------------------------------------------------      ');
  527.  Key;Clrscr;
  528.   Xpos:=12;   Ypos:=6;   Serdraw;
  529.   Xlow:=6; Yhi:=3;
  530.   Vlen:=7; Hlen:=66;    Boxes;
  531. Gotoxy(16,9);Write('SERIES');
  532. Gotoxy(26,3); Write('* Series Circuits Math *');
  533. Gotoxy(34,5); Write('   V = AR  or  A = V/R.  Flow anywhere.');
  534. Gotoxy(34,6); Write('   ~~~~~~      ~~~~~~~~                ');
  535.   Key;
  536.  
  537. Gotoxy(1,13);
  538. Writeln('                    First, a reminder about mathematics.            ');
  539.   Key; Gotoxy(1,13);
  540. Writeln('         A math equation, like A = B, is a statement that A and B   ');
  541. Writeln('         have the same value.  Thus we may freely substitute either ');
  542. Writeln('         for the other.                                             ');
  543.   Writeln;
  544. Writeln('         In addition, to BOTH SIDES of an equation we may add, sub- ');
  545. Writeln('         ract, multiply, or divide by the same quantity.  This fact ');
  546. Writeln('         is the heart of manipulating equations.   Since we treat   ');
  547. Writeln('         both sides the same, they remain equal in value.           ');
  548.   Writeln;
  549. Writeln('          The above are used to put Ohm`s law in different forms.   ');
  550. Writeln('            Different forms are useful for various situations.      ');
  551. Writeln('            --------------------------------------------------      ');
  552.   Key;
  553. Gotoxy(38,7); Write('1. V = A(R1 + R2)');
  554. Gotoxy(38,8); Write('2. V =  AR1 + AR2');
  555. Gotoxy(38,9); Write('3. V =   V1 +  V2   [Volts drops.]');
  556.   Key; Gotoxy(1,22);
  557. Writeln('            Study the above until the `why` of the math is clear.   ');
  558. Writeln('            In parallel flow coming next, the math is different.    ');
  559.   {---------------------------------------------------------------}
  560.   Key;Clrscr;
  561.  
  562.   Xpos:=12;   Ypos:=6;   Pardraw;
  563.   Xlow:=8; Yhi:=3;
  564.   Vlen:=7; Hlen:=64;    Boxes;
  565. Gotoxy(16,10);Write('PARALLEL');
  566. Gotoxy(28,3); Write('* Parallel Circuits Math *');
  567. Gotoxy(34,5); Write('  V = AR  or  A = V/R.  Flow anywhere.');
  568. Gotoxy(34,6); Write('  ~~~~~~      ~~~~~~~~                ');
  569.  
  570.   Key;Gotoxy(1,13);
  571. Writeln('          Before looking at the parallel circuit math, remember this  ');
  572. Writeln('          from series circuits:   Each resistor reduces volts along   ');
  573. Writeln('          the circuit loop, so the total is their sum.                ');
  574.   Writeln;
  575. Writeln('          In parallel flow, the current is separated into branches.   ');
  576. Writeln('          The total is therefore the sum of the branch currents. Our  ');
  577. Writeln('          math starts with this fact.  Here it is.                    ');
  578.   Key;Gotoxy(1,21);
  579. Gotoxy(36,7); Write('1.  A  =  A1  +  A2 ');
  580. Gotoxy(36,8); Write('2. V/R = V/R1 + V/R2');
  581. Gotoxy(36,9); Write('3. 1/R = 1/R1 + 1/R2');
  582.   Key;Gotoxy(1,21);
  583. Writeln('           What happened to our resistors?  Now they are fractions!    ');
  584. Writeln('           And their sum is the reciprocal of the total circuit res-   ');
  585. Writeln('           istance.  We discuss why this is so.                        ');
  586.   Key;Gotoxy(1,13); For I:= 1 to 11 do
  587. Writeln('                                                                      ');
  588.   Gotoxy(1,13);
  589. Writeln('          Resistors reduce flow and pressure.  But we could call them ');
  590. Writeln('          conductors, since they conduct current.  `Adjustors` might   ');
  591. Writeln('          be a better word, because we use them to adjust flow.       ');
  592.   Writeln;
  593. Writeln('          Each parallel branch is somewhat like a separate circuit.   ');
  594. Writeln('          Current flows through each.  So every branch added to the   ');
  595. Writeln('          circuit increases total flow.   Our homes are wired for     ');
  596. Writeln('          parallel use.  Plug in a light, another parallel circuit.   ');
  597.   Writeln;
  598. Writeln('          So each resistor added in parallel increases flow, and thus ');
  599. Writeln('          decreases TOTAL circuit resistance.   That`s the fact.      ');
  600.  
  601.   {---------------------------------------------------------------}
  602.   Key;Clrscr;
  603.  
  604.   Xpos:=12;   Ypos:=6;   Spdraw;
  605.   Xlow:=8; Yhi:=3;
  606.   Vlen:=7; Hlen:=64;    Boxes;
  607. Gotoxy(16,10);Write('SERIES-PARALLEL');
  608. Gotoxy(30,3); Write('* Series-Parallel Math *');
  609. Gotoxy(34,5); Write('  V = AR  or  A = V/R.  Flow anywhere.');
  610. Gotoxy(34,6); Write('  ~~~~~~      ~~~~~~~~                ');
  611.  
  612. Gotoxy(34,7);Write(' 1. Find equivalent resistance for the ');
  613. Gotoxy(34,8);Write('      parallel part.                   ');
  614. Gotoxy(34,9);Write(' 2. Compute volts drops (now series).  ');
  615. Gotoxy(34,10);Write(' 3. Volts now known for parallel part. ');
  616.  
  617.   Key; Gotoxy(1,13);
  618. Writeln('           As summarized above, computing is just successively using ');
  619. Writeln('           the things already developed.  First compute the `equiva- ');
  620. Writeln('           lent resistance` of the parallel part.                    ');
  621.   Writeln;
  622. Writeln('           Put it in the circuit in place of the parallel part.  We  ');
  623. Writeln('           now have a series circuit and can compute the volts drops ');
  624. Writeln('           across each resistor.                                     ');
  625.   Writeln;
  626. Writeln('           The volts drop across the parallel part is the volts avail- ');
  627. Writeln('           able in all parts of the parallel part.  Hand compute a few ');
  628. Writeln('                        circuits, and this will be clear.              ');
  629. Writeln('                        ---------------------------------              ');
  630. Node;
  631.  
  632. end;  (* Procedure MathExplain. *)
  633.   {---------------------------------------------------------------}
  634.                       Procedure TailEnd; Forward;
  635. Procedure Hardware;
  636. Begin   Clrscr;
  637.   Gotoxy(1,1);
  638. Writeln('                 Hardware Demonstrations of Electronics.             ');
  639. Writeln('                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ');
  640. Writeln('       Home demonstrations of flow in circuits can be done with a    ');
  641. Writeln('       modest amount of equipment.  To start, a multimeter, batt-    ');
  642. Writeln('       ery, and a few resistors are the only essentials.  All are    ');
  643. Writeln('       easy to find.  For further details about equipment, see any   ');
  644. Writeln('       books on basic electronics.                                   ');
  645.   Writeln;
  646. Writeln('       Emphasized here is how to approach designing your own experi- ');
  647. Writeln('       ments.  You won`t find this discussed in books.  In addition, ');
  648. Writeln('       the few demonstrations given in books range from poor to lou- ');
  649. Writeln('       sy.  Worse is that mostly they are meant to be done in `elec- ');
  650. Writeln('       tronics laboratories.`  Make the best of them that you can.   ');
  651.   Writeln;
  652. Writeln('       But you have an advantage over the authors of present books.  ');
  653. Writeln('       The advantage is this computer, and these programs. The comp- ');
  654. Writeln('       uter routines will allow you to `design and perform` endless  ');
  655. Writeln('       experiments.  Just select the circuit type wanted, and input  ');
  656. Writeln('       your values.  The computer does the rest.   Up to a point.    ');
  657.   Writeln;
  658. Writeln('       You can`t learn anything in science unless you do much hands- ');
  659. Writeln('       on demonstrating yourself.  That`s why science laboratories   ');
  660. Writeln('       are included in formal training too.  Theory and practice are ');
  661. Writeln('       both essential.  Now for specific suggestions.                ');
  662.   Key;Clrscr;
  663.  
  664. Writeln('       Start `doing experiments` with computer simulations.  Use   ');
  665. Writeln('       small numbers so that it is easy to see what`s happening.   ');
  666. Writeln('       For instance, start with 1 resistor.  Add another of the    ');
  667. Writeln('       same value in series, then in parallel; then use a third.   ');
  668.   Writeln;
  669. Writeln('       Get a notebook and write down results of your studies, in-  ');
  670. Writeln('       cluding questions and problems encountered.  Review your    ');
  671. Writeln('       notebook from time to time.  Find others with whom to dis-  ');
  672. Writeln('       cuss electronics and experiments.                           ');
  673.   Writeln;
  674. Writeln('       Computer simulations of experiments will suggest many cir-  ');
  675. Writeln('       cuits for testing with hardware.  Do it!  With hardware,    ');
  676. Writeln('       however, you will encounter many things hardly mentioned    ');
  677. Writeln('       in books.  Here are some of them.                           ');
  678.   Writeln;
  679. Writeln('       Different kinds of batteries have different voltages, even  ');
  680. Writeln('       for the same cell size.  The more load you put on a battery ');
  681. Writeln('       the more the voltage decreases.  Batteries themselves have  ');
  682. Writeln('       a certain amount of `internal resistance.`  They are just   ');
  683. Writeln('       small chemical factories producing electron flow.  Each     ');
  684. Writeln('       can produce only so much until the chemicals are used up.   ');
  685.   Key; Gotoxy(1,25);For I:=1 to 14 do Writeln;
  686. Gotoxy(1,9);
  687.  
  688. Writeln('       Be cautious about buying kits and umpteen easy electronic pr-   ');
  689. Writeln('       ojects to amaze and mystify your friends.  They are monkey-     ');
  690. Writeln('       see-monkey-do kinds of things.  Little electronics can be       ');
  691. Writeln('       learned from them.  The subject is too complex to be treated    ');
  692. Writeln('       so lightly.  The 4 programs on this disk are only the begin-    ');
  693. Writeln('       ning of many more needed - and to come, I hope.                                    ');
  694.   Writeln;
  695. Writeln('        Throughout these programs, we emphasize the unity of science    ');
  696. Writeln('          within itself, and with its mathematics.  Here are more       ');
  697. Writeln('               suggestions to help understand that unity.               ');
  698. Writeln('               ------------------------------------------               ');
  699.   Key;Clrscr;
  700.  
  701. Writeln('             Relating Electronics to Other Science Topics.            ');
  702. Writeln('             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            ');
  703. Writeln('       At the end of the program Math22 is a list of recommended      ');
  704. Writeln('       books.  You won`t get very far in science without at least     ');
  705. Writeln('       some of them, or the subject matter they contain.  I hope      ');
  706. Writeln('       you have some of them.                                         ');
  707.   Writeln;
  708. Writeln('       Especially important are the books on Physics.  Don`t be       ');
  709. Writeln('       bothered by the word.  It`s quite a good word that refers to   ');
  710. Writeln('       our understanding of matter and energy.  Physics, chemistry    ');
  711. Writeln('       and mathematics are the foundation subjects of all of scien-   ');
  712. Writeln('       ce.  There is vital and fascinating stuff in these subjects.   ');
  713.   Writeln;
  714. Writeln('       What people have not done, however, is to prepare easy intro- ');
  715. Writeln('       ductions to the good stuff.  Here is an example of an easy    ');
  716. Writeln('       introduction, related to electronics too.                     ');
  717.   Key; Clrscr; Gotoxy(1,1);
  718. Writeln('                            The Pendulum.             ');
  719. Writeln('                            ~~~~~~~~~~~~~             ');
  720. Writeln('       Get a small weight, like a nut from a 3/8 inch bolt.  Tie   ');
  721. Writeln('       about a 3 foot length of string or heavy thread to the      ');
  722. Writeln('       nut.  This is your pendulum `experimental apparatus.`       ');
  723.   Writeln;
  724. Writeln('       Wrap the free end of the string around your finger.  Pull   ');
  725. Writeln('       the weight to one side and let it go.  Watch the motion of  ');
  726. Writeln('       the pendulum as it swings back and forth - back and forth.  ');
  727. Writeln('       Sort of hypnotic, isn`t it?                                 ');
  728.   Writeln;
  729. Writeln('       Now change the length of the string.  Just wrap it around   ');
  730. Writeln('       your finger at a different point.  Again watch the motion.  ');
  731. Writeln('       What happens when long versus short lengths are used?       ');
  732. Writeln('                   Why are their motions different?                ');
  733. Writeln('                   --------------------------------                ');
  734.   Key; Gotoxy(1,25); For I:= 1 to 13 do Writeln;
  735.   Gotoxy(1,5);
  736. Writeln('       Pendulum motions, and the math needed to describe them,     ');
  737. Writeln('       comprise other parts of the foundations of science and      ');
  738. Writeln('       mathematics.  Look again at the section `Beyond triangles   ');
  739. Writeln('       (Math22).`  You will see some of the math to be develop-    ');
  740. Writeln('       ed for describing these motions.                            ');
  741.   Writeln;
  742. Writeln('       The programs on this disk describe flow in resistor circu-  ');
  743. Writeln('       its.  This is Direct current.  Alternating current is just  ');
  744. Writeln('       as important, so we want to learn about it too.  Alternat-  ');
  745. Writeln('       ing current is described with pendulum motion math!         ');
  746.   Writeln;
  747. Writeln('       So keep your simple apparatus.  In later programs we will    ');
  748. Writeln('       sketch experiments for it, measurements to be made, and     ');
  749. Writeln('       develop the mathematics.   Perhaps you might want to do at  ');
  750. Writeln('       least some of this yourself.  The essential information is  ');
  751. Writeln('       in the books recommended.                                   ');
  752.   Writeln;
  753. Writeln('              These are long-term projects too (Math21):           ');
  754. Writeln('               Experimenting, observing, and learning.             ');
  755. Writeln('               ---------------------------------------             ');
  756.  
  757. Key;
  758.   Tailend;
  759. end;  (* Procedure Hardware. *)
  760.  
  761.   {---------------------------------------------------------------}
  762. Procedure TailEnd;
  763.   Begin
  764.  
  765. Clrscr;
  766. Gotoxy(20,9); Write('   End Of Program Ohm2 of the Series:');
  767. Gotoxy(20,10); Write('Foundations of Science and Mathematics.');
  768.     Xlow:=17; Yhi:=7; Hlen:=42; Vlen:=4;  Boxes;
  769.  
  770. Gotoxy(20,15); Write('Ohm3 will cover resistor networks, and ');
  771. Gotoxy(21,16); Write('     Maxwell`s Loop Equations.        ');
  772. Gotoxy(21,17); Write('     -------------------------        ');
  773. Gotoxy(23,24);
  774. Write('Press `M` for Menu, `Q` to Quit.');
  775.   Repeat
  776.     Read(Kbd,Ch);
  777.     Ch:=Upcase(Ch);
  778.   until (Ch in ['M','Q']);
  779. If Ch='M' then MainControl;
  780.   Halt;
  781. end;
  782. {====================================================================}
  783. Procedure MainControl;  Label 99;      (******** MAIN CONTROL **********)
  784.   Begin
  785. Assign(Ccontrol,'Control.com');
  786.  
  787.   99:  Clrscr;
  788. Writeln('                        SERIES AND PARALLEL CIRCUITS  ');
  789. Writeln('                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ');
  790. Writeln('                   You input Volts and Resistor values for  ');
  791. Writeln('                              these circuits:               ');
  792.   Gotoxy(1,15);
  793. Writeln('               Series              Parallel            Series-Parallel ');
  794.  
  795.   Gotoxy(1,18);
  796. Writeln('                        Press key for topic wanted. ');
  797. Writeln('                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ');
  798. Writeln('                    1 Series.           4 Math Summary.     ');
  799. Writeln('                    2 Parallel.         5 Math Explanation. ');
  800. Writeln('                    3 Series-Parallel.  6 Hands-on hardware.');
  801. Writeln('                                 C  Control program.        ');
  802. Writeln('                        ____________________________        ');
  803.   Xpos:=11;  Ypos:=10;   Serdraw;
  804.   Xpos:=32;  Ypos:=10;   Pardraw;
  805.   Xpos:=52;  Ypos:=10;   SPdraw;
  806.   Xlow:=5; Yhi:=6;
  807.   Vlen:=9; Hlen:=69;    Boxes;
  808.   {-------------------------------------------------------}
  809.  
  810. Gotoxy(7,20);Write('I want no. ');
  811.  
  812. Repeat
  813.   Read(Kbd,Zh);
  814.   Zh:=UpCase(zh);
  815. until (Zh in ['1','2','3','4','5','6','C']);
  816.  
  817. Case Zh of          (*   Calls procedure wanted.   *)
  818.   '1':  Series;
  819.   '2':  Parallel;
  820.   '3':  SerPar;
  821.   '4':  AllMath;
  822.   '5':  MathExplain;
  823.   '6':  Hardware;
  824.   'C':  Execute(Ccontrol);
  825. end;  (* Case *)
  826.   {---------------------------------------------------------------}
  827. Repeat
  828.   Gotoxy(51,19);  Write('Press letter for next job.');
  829.   Gotoxy(52,21);  Write('`A` Another of these.');
  830.   Gotoxy(52,22);  Write('`M` Back to Menu.');
  831.   Gotoxy(52,23);  Write('`Q` Quit.');
  832.  
  833.     Repeat
  834.       Read(Kbd,ch);
  835.       ch:=UpCase(ch);
  836.     until (Ch IN ['A','M','Q']);
  837.  
  838. If (Ch='A') then  begin
  839.   if (Zh='1') then Series;
  840.   if (Zh='2') then Parallel;
  841.   if (Zh='3') then SerPar;
  842.     end;  (* Same circuit computing. *)
  843.  
  844. If (Ch='M') then goto 99;
  845.  
  846. until (Ch='Q');
  847.  
  848. End;   (* procedure MainControl. *)
  849. {====================================================================}
  850.  
  851. Begin                (*  ***  MAIN PROGRAM *** *)
  852.  
  853. Clrscr;
  854.   Gotoxy(1,6);
  855. Writeln('                Electronics #2  Series & Parallel Circuits.               ');
  856. Writeln('                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ');
  857.   Gotoxy(1,11);
  858. Writeln('               Second electronics program.  Covers electron   ');
  859. Writeln('                   flow in Series and Parallel Circuits.      ');
  860.   Writeln;
  861. Writeln('         A mathematics section explains why Ohm`s law is different   ');
  862. Writeln('              for the circuits, and relates it to other math.   ');
  863.  
  864.   Xlow:=7; Yhi:=9; Hlen:=61; Vlen:=7;  Boxes;
  865.  
  866. Gotoxy(70,25);Write('Oct 1985');
  867. Gotoxy( 1,25);Write('Ohm2');
  868.   Key;
  869. Maincontrol;
  870.  
  871.  
  872. End.     (* Main Program. *)
  873. {====================================================================}